package com.yxq.mdt.app.modules.order.model;


import com.yxq.mdt.app.base.RespBase;
import com.yxq.mdt.app.base.RespBasePay;
import com.yxq.mdt.app.modules.order.bean.ExpressBean;
import com.yxq.mdt.app.modules.order.bean.OrderCommentPreviewBean;
import com.yxq.mdt.app.modules.order.bean.OrderConfirmBean;
import com.yxq.mdt.app.modules.order.bean.OrderDetailBean;
import com.yxq.mdt.app.modules.order.bean.OrderListBean;
import com.yxq.mdt.app.modules.order.bean.OrderPayResultBalanceBean;
import com.yxq.mdt.app.modules.order.bean.OrderPayResultWxBean;
import com.yxq.mdt.app.modules.order.bean.OrderRefundDetailBean;
import com.yxq.mdt.app.modules.order.bean.OrderRefundPreviewBean;
import com.yxq.mdt.app.modules.order.bean.OrderSubmitResult;
import com.yxq.mdt.app.modules.order.bean.UploadImageResultBean;
import com.yxq.mdt.app.net.API;

import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;

public interface OrderApi {

    /**
     * 订单-提交界面
     *
     * @return
     */
    @POST(API.HOST_BASE_URL + "api/order/new-submit-preview")
    @FormUrlEncoded
    Observable<RespBase<OrderConfirmBean>> preview(@Field("access_token") String access_token, @Field("address_id") String address_id, @Field("mch_list") String mch_list);

    /**
     * 订单-提交订单
     *
     * @return
     */
    @POST(API.HOST_BASE_URL + "api/order/new-submit")
    @FormUrlEncoded
    Observable<RespBase<OrderSubmitResult>> submit(@Field("access_token") String access_token, @Field("address_id") String address_id, @Field("mch_list") String mch_list, @Field("use_integral") int use_integral, @Field("payment") int payment);

    /**
     * 订单-订单列表
     *
     * @return
     */
    @GET(API.HOST_BASE_URL + "api/order/list")
    Observable<RespBase<OrderListBean>> list(@Query("access_token") String access_token, @Query("status") String status, @Query("page") int page);

    /**
     * 订单-支付（余额）
     *
     * @return
     */
    @GET(API.HOST_BASE_URL + "api/order/pay-data")
    Observable<RespBase<OrderPayResultBalanceBean>> payBalance(@Query("access_token") String access_token, @Query("order_id") String order_id, @Query("pay_type") String pay_type, @Query("_platform") String platform);

    /**
     * 订单-支付（微信）
     *
     * @return
     */
    @GET(API.HOST_BASE_URL_PAY + "api/order/pay-data")
    Observable<RespBasePay<OrderPayResultWxBean>> payWX(@Query("access_token") String access_token, @Query("order_id") String order_id, @Query("pay_type") String pay_type, @Query("parent_user_id") String parent_user_id, @Query("condition") String condition, @Query("_platform") String platform,@Query("goods_state") int goods_state);

    /**
     * 订单-查看订单详情
     *
     * @return
     */
    @GET(API.HOST_BASE_URL + "api/order/detail")
    Observable<RespBase<OrderDetailBean>> detail(@Query("access_token") String access_token, @Query("order_id") String order_id);

    /**
     * 订单-删除订单
     *
     * @return
     */
    @GET(API.HOST_BASE_URL + "api/order/delete")
    Observable<RespBase<String>> delete(@Query("access_token") String access_token, @Query("order_id") String order_id);


    /**
     * 订单-查看物流信息
     * @param order_id
     * @param type 订单类型（1=普通订单 2=秒杀订单）
     * @return
     */
    @GET("mdf/api/kdnExpress/getExpressDetail")
    Observable<RespBase<ExpressBean>> express(@Query("orderId") String order_id, @Query("orderType") String type);

    /**
     * 订单-取消订单/申请退款
     *
     * @return
     */
    @GET(API.HOST_BASE_URL + "api/order/revoke")
    Observable<RespBase<String>> revoke(@Query("access_token") String access_token, @Query("order_id") String order_id);


    /**
     * 订单-确认收货
     *
     * @return
     */
    @GET(API.HOST_BASE_URL + "api/order/confirm")
    Observable<RespBase<String>> confirm(@Query("access_token") String access_token, @Query("order_id") String order_id);

    /**
     * 订单>申请售后预览界面
     *
     * @return
     */
    @GET(API.HOST_BASE_URL + "api/order/refund-preview")
    Observable<RespBase<OrderRefundPreviewBean>> refundPreview(@Query("access_token") String access_token, @Query("order_detail_id") String order_detail_id);


    /**
     * 订单>评价>上传图片
     *
     * @return
     */
    @POST(API.HOST_BASE_URL + "api/default/upload-image")
    Observable<RespBase<UploadImageResultBean>> uploadImage(@Body RequestBody body);


    /**
     * 订单>提交退货/换货
     *
     * @return
     */
    @POST(API.HOST_BASE_URL + "api/order/refund")
    @FormUrlEncoded
    Observable<RespBase<String>> refund(@Field("access_token") String access_token, @Field("type") int type, @Field("order_detail_id") String order_detail_id, @Field("desc") String desc, @Field("pic_list") String pic_list, @Field("orderType") String orderType);

    /**
     * 订单>评论预览
     *
     * @return
     */
    @GET(API.HOST_BASE_URL + "api/order/comment-preview")
    Observable<RespBase<OrderCommentPreviewBean>> commentPreview(@Query("access_token") String access_token, @Query("order_id") String order_id, @Query("type") String type);

    /**
     * 订单-提交评论
     *
     * @return
     */
    @POST(API.HOST_BASE_URL + "api/order/comment")
    @FormUrlEncoded
    Observable<RespBase<String>> orderComment(@Field("access_token") String access_token, @Field("order_id") String order_id, @Field("type") String type, @Field("goods_list") String goods_list);

    /**
     * 售后订单详情
     *
     * @return
     */
    @GET(API.HOST_BASE_URL + "api/order/refund-detail")
    Observable<RespBase<OrderRefundDetailBean>> refundDetail(@Query("access_token") String access_token, @Query("order_refund_id") String order_refund_id);

    /**
     * 订单>提交退货物流
     *
     * @return
     */
    @POST(API.HOST_BASE_URL + "api/order/refund-send")
    @FormUrlEncoded
    Observable<RespBase<String>> refundSend(@Field("access_token") String access_token, @Field("order_refund_id") String order_refund_id, @Field("express") String express, @Field("express_no") String express_no, @Field("orderType") String orderType);

}
